package com.eerl.pdev.util;


import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.project.Project;

import java.util.Objects;

public class ProjectFileUtil {
    public static void saveFile(AnActionEvent e) {
        // 保存当前文件
        Project project = e.getProject();
        if (project != null) {
            Document document = Objects.requireNonNull(e.getData(CommonDataKeys.EDITOR)).getDocument();
            FileDocumentManager.getInstance().saveDocument(document);
        }
    }
}
